package day0920_1;

import java.util.TreeSet;

class Rabbit implements  Comparable{//1.
    int age;
    public int compareTo(Object o) {//2. this-o： 升序
        return this.age  -  ((Rabbit)o).age;
    }
}





public class T1 {
    public static void main(String[] args) {
        TreeSet<Rabbit>  set=new TreeSet();//3.
        //4.
        Rabbit  biDeTu=new Rabbit();   biDeTu.age=3;
        Rabbit  yueYuTu=new Rabbit();  yueYuTu.age=30;
        Rabbit  hmlt=new Rabbit();  hmlt.age=1;
        set.add(biDeTu);   set.add(yueYuTu);  set.add(hmlt);
        for( Rabbit  r  : set){
            System.out.println("r = " + r.age);
        }
    }
}







